import asyncio
from .app.farfetch import main as farfetch_main

async def main(semaphore: asyncio.Semaphore, url: str, base_url:str, proxy: str):
    main_dict = {
        'farfetch': farfetch_main,
    }
    async with semaphore:
        result = await main_dict[base_url](semaphore, url, proxy)
    return result

MAX_CONCURRENCY = 24

def run(url: str, base_url: str, proxy: str):
    semaphore = asyncio.Semaphore(MAX_CONCURRENCY)
    result = asyncio.run(main(semaphore, url, base_url, proxy))
    return result
